From: Chad Horohoe Date: Thu, 18 Apr 2013 15:29:21 +0000 (-0400) Subject: Handle search engine returning status objects to the API X-Git-Tag: 1.31.0-rc.0~19922 X-Git-Url: http://git.cyclocoop.org/%7D%7Cconcat%7B?a=commitdiff_plain;h=ea430cba3d7999e39f77833e19456a4abac840dc;p=lhc%2Fweb%2Fwiklou.git Handle search engine returning status objects to the API This is a followup to I54ab5207, which allowed search backends to return status objects. We handled it in Special:Search, but the API was overlooked. Bug: 47353 Change-Id: Ib7abe8d5bc19d27c472053602c0e43cb1301b078 --- diff --git a/includes/api/ApiQuerySearch.php b/includes/api/ApiQuerySearch.php index 861833919b..ab78ba6710 100644 --- a/includes/api/ApiQuerySearch.php +++ b/includes/api/ApiQuerySearch.php @@ -93,6 +93,8 @@ class ApiQuerySearch extends ApiQueryGeneratorBase { } if ( is_null( $matches ) ) { $this->dieUsage( "{$what} search is disabled", "search-{$what}-disabled" ); + } elseif( $matches instanceof Status && !$matches->isGood() ) { + $this->dieUsage( $matches->getWikiText(), 'search-error' ); } $apiResult = $this->getResult(); @@ -345,6 +347,7 @@ class ApiQuerySearch extends ApiQueryGeneratorBase { return array_merge( parent::getPossibleErrors(), array( array( 'code' => 'search-text-disabled', 'info' => 'text search is disabled' ), array( 'code' => 'search-title-disabled', 'info' => 'title search is disabled' ), + array( 'code' => 'search-error', 'info' => 'search error has occurred' ), ) ); }